package com.younion.action.interactive.baidu.api;

import com.younion.common.base.BaseAPI;

public class BaiduMapApi extends BaseAPI {
	private static final String API_KEY = "8fe253f35fdf81b195f44520c6d855c2";
	private static final String HOST = "http://api.map.baidu.com/geocoder?";
	private static final String OUTPUT = "json";

	public String getLocationByAddress(String address) throws Exception {
		address = java.net.URLEncoder.encode(address);
		StringBuilder url = new StringBuilder();
		url.append(HOST).append("address=").append(address).append("&output=")
				.append(OUTPUT).append("&key=").append(API_KEY);
		return doGet(url.toString());
	}

	public String getAddressByLocation(String location) throws Exception {
		StringBuilder url = new StringBuilder();
		url.append(HOST).append("location=").append(location)
				.append("&output=").append(OUTPUT).append("&key=").append(
						API_KEY);
		return doGet(url.toString());
	}
}
